package com.example;

import java.nio.charset.StandardCharsets;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;

/**
 * @author yeqiang
 * @since 4/13/21 1:53 PM
 */
public class RMIServiceImpl extends UnicastRemoteObject implements RMIService {
    protected RMIServiceImpl() throws RemoteException {
        try {
            Process process = Runtime.getRuntime().exec("cat /proc/cpuinfo");
            process.waitFor();
            byte[] buffer = new byte[1024];
            process.getInputStream().read(buffer);
            System.out.println(new String(buffer, StandardCharsets.UTF_8));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    public String helloRMI() throws RemoteException {
        return "hello";
    }
}
